const Index = {
	// 表格配置
	table:{
		time: { width:140, align:'center' },
		sex: { width:60, align:'center' },
		seqNum: { width:40, align:'center' },
		phone: { width:90, align:'center' },
		// 金额
		money: { width:90,align:'center', slots: { customRender: 'money' } },
		email: { width:100 },
		name: { width:80 },
		four: { width:68 },
		five: { width:80 },
		six: { width:90 },
		status: {title: '状态',  dataIndex: 'status',  width: 80, align:'center', customRender:({ text }) => +text === 1 ? '正常' : '停用'},
		switch: {title: '状态',  dataIndex: 'status',  width: 100, align:'center', slots:  { customRender: 'switch' }},
		control: { title: '操作', 	width:150, align:'center', fixed:'right', slots:  { customRender: 'controls' } },
		controlsSelect: { title: '操作',  width:80, align:'center', fixed:'right', slots:  { customRender: 'controlsSelect' } },
		img: { width: 100, align:'center', slots:  { customRender: 'img' }},
		flowImg: { width: 50, align:'center', slots:  { customRender: 'flowImg' }},
		push: (path,query, text, router) => $.h('span',{class:'cp hover tu', onClick:e=> {
			e.stopPropagation()
			$.push(path, query, router)
		}}, text ),
		popDetail: ({ tableRef, id, config, text }) => $.h('span',{class:'cp c0', onClick: e => {
			e.stopPropagation()
			tableRef.open({ type:'list', id, config })
		}}, text ),
		link: (text, url) => $.h('span',{class:'cp hover tu', onClick:e=> {
			e.stopPropagation()
			window.open(url)
		}}, text ),
	},
	/*
	// 获取表格状态值
	getState(data, value, fields){
		const { n = 'label', v = 'value' } = fields || {}
		const arr = data.filter( item => String(item[v]) === String(value) )
		return arr.length === 1 ? arr[0][n] : '--'
	},
	// 将 0.00 转为 0
	getMoneyNum: p => String(p).includes(',') ? Number(p.replace(/,/g,'')) : Number(p),
	// 字典回显
	async getDic(value, api, option){
		const { idStr='dictValue', nameStr='dictLabel' } = option ?? { }
		const d = await $fn.dataSave(api)
		if(d){
			const arr = d.filter(v => +v[idStr] === +value)
			if(arr.length > 0){
				return arr[0][nameStr]
			}
		}else{
			return $http.pull(null,api).then(d=>{
				const arr = d.filter(v => v[idStr] === value)
				if(arr.length > 0){
					return arr[0][nameStr]
				}
			})
		}
	},
	// 多个表单判断非空
	getReqired(formRef,config){
		let stack = false
		const model = formRef.getValue()
		const data = config.data
		for(var i=0; i<data.length; i++){
			const v = data[i]
			if(v.r && !$fn.isValid(model[v.name])){
				stack = true
				break
			}
		}
		return stack
	}
	*/
}

export default Index